; *** Hip
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com
(translate
 ("Red" "红方")("Blue" "蓝方")
 ("Hip 4x4" "禁方棋 4x4") ("Hip 5x5" "禁方棋 5x5") ("Hip 6x6" "禁方棋 6x6")
 ("Hip 7x7" "禁方棋 4x4") ("Hip 8x8" "禁方棋 8x8")
 ("Line Hip 4x4" "连线棋 4x4")("Line Hip 5x5" "连线棋 5x5")
 ("Line Hip 6x6" "连线棋 6x6")("Line Hip 7x7" "连线棋 7x7")
 ("Line Hip 8x8" "连线棋 8x8")
)

(define add-to-empty ((verify empty?) add) )

(define squares4x4
  ;2x2
	(relative-config Ball n Ball e Ball s Ball)               ; 0:1
  ;3x3
    (relative-config Ball ne Ball nw Ball sw Ball)            ; 1:1
	(relative-config Ball n n Ball e e Ball s s Ball)         ; 0:2
  ;4x4
	(relative-config Ball e ne Ball n nw Ball w sw Ball)      ; 1:2
	(relative-config Ball w nw Ball n ne Ball e se Ball)
	(relative-config Ball n n n Ball e e e Ball s s s Ball)   ; 0:3
)
(define squares5x5
	(relative-config Ball ne ne Ball nw nw Ball sw sw Ball)       ; 2:2
	(relative-config Ball e e ne Ball n n nw Ball w w sw Ball)    ; 1:3
	(relative-config Ball w w nw Ball n n ne Ball e e se Ball)
	(relative-config Ball n n n n Ball e e e e Ball s s s s Ball) ; 0:4
)
(define squares6x6
	(relative-config Ball e ne ne Ball n nw nw Ball w sw sw Ball)       ; 2:3
	(relative-config Ball w nw nw Ball n ne ne Ball e se se Ball)
	(relative-config Ball e e e ne Ball n n n nw Ball w w w sw Ball)    ; 1:4
	(relative-config Ball w w w nw Ball n n n ne Ball e e e se Ball)
	(relative-config Ball n n n n n Ball e e e e e Ball s s s s s Ball) ; 0:5
)
(define squares7x7
	(relative-config Ball ne ne ne Ball nw nw nw Ball sw sw sw Ball)          ; 3:3
	(relative-config Ball e e ne ne Ball n n nw nw Ball w w sw sw Ball)       ; 2:4
	(relative-config Ball w w nw nw Ball n n ne ne Ball e e se se Ball)
	(relative-config Ball e e e e ne Ball n n n n nw Ball w w w w sw Ball)    ; 1:5
	(relative-config Ball w w w w nw Ball n n n n ne Ball e e e e se Ball)
	(relative-config Ball n n n n n n Ball e e e e e e Ball s s s s s s Ball) ; 0:6
)
(define squares8x8
	(relative-config Ball e ne ne ne Ball n nw nw nw Ball w sw sw sw Ball)          ; 3:4
	(relative-config Ball w nw nw nw Ball n ne ne ne Ball e se se se Ball)
	(relative-config Ball e e e ne ne Ball n n n nw nw Ball w w w sw sw Ball)       ; 2:5
	(relative-config Ball w w w nw nw Ball n n n ne ne Ball e e e se se Ball)
	(relative-config Ball e e e e e ne Ball n n n n n nw Ball w w w w w sw Ball)    ; 1:6
	(relative-config Ball w w w w w nw Ball n n n n n ne Ball e e e e e se Ball)
	(relative-config Ball n n n n n n n Ball e e e e e e e Ball s s s s s s s Ball) ; 0:7
)

(game
    (title "Hip 4x4")
	(description "双方交替落子。形成正方形的一方输。\\注意，任何角度的正方形均计算在内！")
    (history "`Hip` was invented by Martin Gardner and appears in his
	   book `My Best Mathematical and Logic Puzzles.`  Why `Hip`?  Everybody
	   know that hipsters distain squares!\\Our `Line Hip` is a new variation
	   of that game.")
    (strategy "Draws are possible on boards up to 6x6, but impossible on
	   larger boards.  On the even-order boards (4x4, 6x6, 8x8) it is possible
	   for the second player to play symmetrically to the first player.  In this
	   way the second player can be assured at least a draw  For the 8x8
	   board or some symmetries on a 6x6, he can be assured a win.  For this
	   reason, Martin Gardner advises play on a 7x7 board, where such strategies
	   fail due to the central square, and there is no possibility of a draw.")
	(drop-sound "Audio\\Spiralin.wav")
	(players Red Blue)
    (turn-order Red Blue)
    (board
       (image "images\Chess\SHaag\chess4x4.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d" (49 0)) ; files
              ("4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
     )  

    (piece
		(image Red "images\TicTacToe\rballs.bmp"
		       Blue "images\TicTacToe\bballs.bmp")
        (name Ball)
		(help "Ball: Drops to any empty square")
		(description "Ball\A Ball can drop on any empty square.")
        (drops (add-to-empty))
	)
   (board-setup
        (Red (Ball off 99))
        (Blue (Ball off 99))
   )
   (loss-condition (Red Blue)
	  	(or (squares4x4))
   )
)

(variant
    (title "Hip 5x5")
    (board
       (image "images\Chess\SHaag\Chess5x5.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e" (49 0)) ; files
              ("5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
    (loss-condition (Red Blue)
	  	(or (squares4x4)(squares5x5))
    )
)

(variant
    (title "Hip 6x6")
    (board
       (image "images\Chess\SHaag\Chess6x6.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e/f" (49 0)) ; files
              ("6/5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
    (loss-condition (Red Blue)
	  	(or (squares4x4)(squares5x5)(squares6x6))
    )
)

(variant
    (title "Hip 7x7")
    (board
       (image "images\Chess\SHaag\Chess7x7.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e/f/g" (49 0)) ; files
              ("7/6/5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
    (loss-condition (Red Blue)
	  	(or (squares4x4)(squares5x5)(squares6x6)(squares7x7))
    )
)

(variant
    (title "Hip 8x8")
    (board
       (image "images\Chess\SHaag\Chess8x8.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e/f/g/h" (49 0)) ; files
              ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
    (loss-condition (Red Blue)
	  	(or (squares4x4)(squares5x5)(squares6x6)(squares7x7)(squares8x8))
    )
)

(variant (title "-")) ; -------------------------------------

(define three-in-a-row
  ;north
	(relative-config RedBall n RedBall n RedBall)          
	(relative-config BlueBall n BlueBall n BlueBall)          
  ;east
    (relative-config RedBall e RedBall e RedBall)
	(relative-config BlueBall e BlueBall e BlueBall)
  ;north-east
	(relative-config RedBall ne RedBall ne RedBall)    
	(relative-config BlueBall ne BlueBall ne BlueBall)    
  ;north-west
	(relative-config RedBall nw RedBall nw RedBall)  
	(relative-config BlueBall nw BlueBall nw BlueBall)  
)

(define common-line
	(description "双方交替下子，每方可选择下红子或蓝子。\先把三个同色子连成一条线的获胜。")
    (strategy "Check the squares next to where you are considering
	   dropping a ball to, and also the squares two squares away, for
	   a ball of the same color.  This will avoid an instant loss.  To
	   find safe moves look for dropping a red ball next to a blue ball,
	   and vice versa.")
	(players First-Player Second-Player Player)
    (turn-order (First-Player Player) (Second-Player Player))
    (piece
		(image Player "images\TicTacToe\rballs.bmp")
        (name RedBall)
		(help "Ball: Drops to any empty square")
		(description "Ball\A Ball can be dropped on any empty square.")
        (drops (add-to-empty))
	)
	(piece
		(image Player "images\TicTacToe\bballs.bmp")
        (name BlueBall)
		(help "Ball: Drops to any empty square")
		(description "Ball\A Ball can be dropped on any empty square.")
        (drops (add-to-empty))
	)
    (piece (name Ball))
	(board-setup
        (Player (RedBall off 99))
        (Player (BlueBall off 99))
    )
    (win-condition (Player)
	  	(or (three-in-a-row))
    )
)

(variant
    (title "Line Hip 4x4")
	(common-line)
)

(variant
    (title "Line Hip 5x5")
	(common-line)
    (board
       (image "images\Chess\SHaag\Chess5x5.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e" (49 0)) ; files
              ("5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
)

(variant
    (title "Line Hip 6x6")
	(common-line)
    (board
       (image "images\Chess\SHaag\Chess6x6.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e/f" (49 0)) ; files
              ("6/5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
)

(variant
    (title "Line Hip 7x7")
	(common-line)
    (board
       (image "images\Chess\SHaag\Chess7x7.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e/f/g" (49 0)) ; files
              ("7/6/5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
)

(variant
    (title "Line Hip 8x8")
	(common-line)
    (board
       (image "images\Chess\SHaag\Chess8x8.bmp")
       (grid
          (start-rectangle 5 5 53 53)
          (dimensions
              ("a/b/c/d/e/f/g/h" (49 0)) ; files
              ("8/7/6/5/4/3/2/1" (0 49)) ; ranks
          )
          (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			     (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
          )
	   )
    )
)

